package com.yxplearn.mybatisplus.util.quartz;

import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author      : yang.xp
 * @date        : 2022/2/11 12:03
 * @description : 定时任务执行的demo，可用来定时推送，定时扫库等等
 */
@Log4j2
//@Component
public class QuartzDemo {

    //每隔五秒
    @Async("QuartzThreadPool")
    @Scheduled(cron = "0/5 * * * * ? ")
    public void process1() {
        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("我是定时任务！1");
    }

    //每隔五秒
    @Async("QuartzThreadPool")
    @Scheduled(cron = "0/5 * * * * ? ")
    public void process2() {
        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("我是定时任务！2");
    }

}
